public class SyncExample {
    private int v1 = 0;
    private int v2 = 0;
    synchronized public long getV() {
        return v1 + v2;
    }
    synchronized public void transferV() {
        v1++;
        try {
            Thread.sleep(10L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        v2--;
    }
}
